<template>
  <!-- 订单详情页 -->
  <div>
    <FilterTable
      ref="table"
      :columns="tableColumns"
      :dataSource="partList"
      :isSelectColumn="false"
      :isMemoryPagination="true"
      columnsRef="partPartPurchaseUndeliveredBatchCancelOrderDetail"
      :onColumnsChange="columns => (this.tableColumns = columns)"
    >
      <!-- <template slot="controls">
        <el-button size="small" type="primary">导出</el-button>
        <el-button size="small" type="danger">打印</el-button>
      </template>-->
    </FilterTable>
    <div class="bottomBtnWrap">
      <!-- <el-button @click="handleClose">取 消</el-button> -->
      <el-button type="primary" @click="handleClose">确 定</el-button>
    </div>
  </div>
</template>

<script>
import { queryOrderPartDetailByOrderNo } from '@/api/part/partPurchase/purchaseOrder';

export default {
  props: {
    orderId: String
  },
  data() {
    return {
      tableColumns: this.createTableColumns(),
      fetchapi: queryOrderPartDetailByOrderNo,
      partList: []
    };
  },
  created() {
    this.$nextTick(() => {
      this.queryDetailList();
    });
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '配件代码',
          dataIndex: 'partNo'
        },
        {
          title: '底盘号',
          dataIndex: 'vVin'
        },
        {
          title: '厂家配件代码',
          dataIndex: 'a3'
        },
        {
          title: '含税采购单价',
          dataIndex: 'planPrice',
          precision: 6
        },
        {
          title: '不含税采购单价',
          dataIndex: 'nPriceNoTax',
          precision: 6
        },
        {
          title: '仅辖区发货',
          dataIndex: 'shipMark'
        },
        {
          title: '订货数量',
          dataIndex: 'nOrderQty'
        },
        {
          title: '建议数量',
          dataIndex: 'nSuggestQty'
        },
        {
          title: '欠料数量',
          dataIndex: 'a9'
        },
        {
          title: '需求日期',
          dataIndex: 'dDemand',
          dateFormat: 'yyyy-MM-dd',
          width: 150
        },
        {
          title: '含税采购金额',
          dataIndex: 'total_planPrice',
          precision: 6
        },
        {
          title: '不含税采购金额',
          dataIndex: 'total_nPriceNoTax',
          precision: 6
        },
        {
          title: '配件名称',
          dataIndex: 'partName'
        },
        {
          title: '主组号',
          dataIndex: 'a14'
        },
        {
          title: '原始订单号',
          dataIndex: 'vOldBillNo'
        },
        {
          title: '分店订货数量',
          dataIndex: 'nSubOrderQty'
        },
        {
          title: '到货数量',
          dataIndex: 'nArrivalQty'
        },
        {
          title: '操作员',
          dataIndex: 'a18'
        },
        {
          title: 'ETKA',
          dataIndex: 'a19'
        },
        {
          title: '委托书编号',
          dataIndex: 'a20'
        },
        {
          title: '送修日期',
          dataIndex: 'dEnter'
        },
        {
          title: '厂家处理说明',
          dataIndex: 'vSuhandleDesc'
        },
        {
          title: 'R3三包采购',
          dataIndex: 'a23'
        }
      ];
    },
    // 根据订单id订单配件详情
    async queryDetailList() {
      this.$refs.table.START_LOADING();
      let res = await queryOrderPartDetailByOrderNo({
        orderNo: this.orderId
      });
      if ((res.resultCode = 200)) {
        this.partList = res.data;
      }
      this.$refs.table.STOP_LOADING();
    },
    // 弹窗关闭事件
    handleClose() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.bottomBtnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
